using System.Collections.Generic;
using System.Text;

namespace OracleInternal.SqlAndPlsqlParser.LocalParsing
{
	internal class OracleLpSelectClause : OracleLpStatementElement, IOracleLpColumnDescriptorContainer
	{
		protected OracleLpSelectionType m_vSelectionType;

		protected bool m_vBulkCollect;

		protected List<OracleLpSelectTerm> m_vSelectList = new List<OracleLpSelectTerm>();

		protected List<OracleLpName> m_vIntoList = new List<OracleLpName>();

		protected List<OracleLpColumnDescriptor> m_vColumnDescriptors;

		internal override OracleLpStatementElementType ElementType => OracleLpStatementElementType.SelectClause;

		public OracleLpSelectionType SelectionType
		{
			get
			{
				return m_vSelectionType;
			}
			set
			{
				m_vSelectionType = value;
			}
		}

		public bool BulkCollect
		{
			get
			{
				return m_vBulkCollect;
			}
			set
			{
				m_vBulkCollect = value;
			}
		}

		public List<OracleLpSelectTerm> SelectList => m_vSelectList;

		public List<OracleLpName> IntoList => m_vIntoList;

		public List<OracleLpColumnDescriptor> ColumnDescriptors
		{
			get
			{
				if (m_vColumnDescriptors == null)
				{
					Resolve();
				}
				return m_vColumnDescriptors;
			}
		}

		public OracleLpSelectClause(OracleLpQueryBlock parent)
			: base(parent)
		{
		}

		public virtual void Resolve()
		{
			m_vColumnDescriptors = new List<OracleLpColumnDescriptor>();
			foreach (OracleLpSelectTerm vSelect in m_vSelectList)
			{
				m_vColumnDescriptors.AddRange(vSelect.ColumnDescriptors);
			}
		}

		internal override void ToString(StringBuilder sb)
		{
			string depthIndent = base.DepthIndent;
			sb.Append(depthIndent);
			sb.Append("Select List:\n");
			m_vSelectList.ForEach(delegate(OracleLpSelectTerm st)
			{
				st.ToString(sb);
			});
		}
	}
}
